package com.ytjj.qmyx.mall.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ytjj.qmyx.mall.enums.OtherEnum;
import com.ytjj.qmyx.mall.model.DynamicDto;
import com.ytjj.qmyx.mall.service.DynamicService;
import com.ytjj.qmyx.mall.service.OtherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 *
 *  *
 **/
@Service
public class OtherServiceImpl implements OtherService {
    @Autowired
    private DynamicService dynamicService;

    @Override
    public Object getOtherList() {
        OtherEnum[] values = OtherEnum.values();
        List<JSONObject> list = new ArrayList<>();
        for (OtherEnum value : values) {
            JSONObject js = new JSONObject();
            js.put("id",value.getId());
            js.put("img",value.getImg());
            js.put("name",value.getName());
            DynamicDto dynamic = dynamicService.getDynamicById(value.getId());
            String dynamicType = null;
            if (null != dynamic) {
                dynamicType = dynamic.getDynamicType();
            }
            js.put("dynamicType", dynamicType);
            list.add(js);
        }
        return list;
    }
}
